﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using SyncLib;
using DevComponents.DotNetBar.SuperGrid;
using System.IO;
using SyncLib.Interface;

namespace SyncConfig.Dialog
{
    public partial class PickClass : SyncConfig.Dialog.BaseDialog
    {
        public string AssemblyPath { get; set; }
        public PickClass()
        {
            InitializeComponent();
        }

        private void PickClass_Load(object sender, EventArgs e)
        {
            Assembly ass = Assembly.LoadFile(Path.Combine( Application.StartupPath, AssemblyPath));
            Type[] allType=ass.GetTypes();
            DataTable tblData = new DataTable();
            tblData.Columns.Add("ClassName");
            tblData.Columns.Add("Namespace");
            tblData.Columns.Add("DataType",typeof(object));
            Type baseType=typeof(IKeeperSync);
            foreach (Type t in allType)
            {
                if (baseType.IsAssignableFrom(t))
                    tblData.Rows.Add(t.Name, t.Namespace,t);
            }
            superGridControl1.PrimaryGrid.DataSource = tblData;
        }
        public DataRowView SelectedRow;
        private void superGridControl1_RowDoubleClick(object sender, DevComponents.DotNetBar.SuperGrid.GridRowDoubleClickEventArgs e)
        {

            GridRow row = e.GridRow as GridRow;
            SelectedRow = row.DataItem as DataRowView;
            DialogResult = DialogResult.OK;
        }
    }
}
